//
//  WebViewController.m
//  多玩盒子
//
//  Created by 刘胜 on 16/2/27.
//  Copyright © 2016年 刘胜. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>

@property (nonatomic, retain) UIWebView *webView;

@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    UIImage *image1 = [UIImage imageNamed:@""];
//    image1 = [image1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:image1 style:UIBarButtonItemStylePlain target:self action:@selector(fanhui:)];
    
    self.view.backgroundColor = [UIColor whiteColor];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.mol]];
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];

    self.webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    self.webView.delegate = self;

}
///出现错误时
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    UIAlertController * aler = [UIAlertController alertControllerWithTitle:@"" message:@"连接失败" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *aaa = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
    }];
    [aler addAction:aaa];
    [self presentViewController:aler animated:YES completion:^{
        
        
    }];
    
}
///将要加载
-(void)webViewDidStartLoad:(UIWebView *)webView{
    
}

///完成加载
-(void)webViewDidFinishLoad:(UIWebView *)webView{
   
}


-(void)fanhui:(UIBarButtonItem *)btn{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
